package bid.yanhj.common.util;

import java.io.Serializable;

/**
 * 日志基础信息类.
 * 
 * @author yanhaijiang
 *
 */
public class MetaInfo implements Serializable {

	private static final String STATUS_DEF = "DEF";

	private static final long serialVersionUID = -198875474009728992L;

	private static final int BASE_NUMBER = 100000000;

	private static final int MAX_LENGTH = 22;

	private String uuid;

	private String method;

	private String status = STATUS_DEF;

	private long ftime;

	private long bid;

	/**
	 * Constructor.
	 * 
	 * @param method
	 *            URI
	 */
	public MetaInfo(String method) {
		this.method = method;
		ftime = System.currentTimeMillis();
		if (uuid == null) {
			long id = System.currentTimeMillis();
			double math = Math.random();
			uuid = (long) (math * ftime) + "-" + id + "-" + (long) (math * id * BASE_NUMBER);
			if (uuid.length() > MAX_LENGTH) {
				uuid = uuid.substring(0, MAX_LENGTH);
			}
		}
	}

	/**
	 * @return the uuid
	 */
	public String getUuid() {
		return uuid;
	}

	/**
	 * @return the method
	 */
	public String getMethod() {
		return method;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the ftime
	 */
	public long getFtime() {
		return System.currentTimeMillis() - ftime;
	}

	/**
	 * @return the bid
	 */
	public long getBid() {
		return bid;
	}

	/**
	 * @param bid
	 *            the bid to set
	 */
	public void setBid(long bid) {
		this.bid = bid;
	}
}